package com.panda.controller.article;

import com.panda.service.ArticleService;
import com.panda.utils.RespondResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("backstage/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @GetMapping("createdArticleOfWeek")
    public RespondResult createdArticleCount(){
        return articleService.createdArticleStatistic();
    }

    @GetMapping("auditList")
    public RespondResult auditArticleTitleList(@RequestParam String pageNum){
        return articleService.auditArticleTitleList(Integer.parseInt(pageNum));
    }

    @GetMapping("auditContent")
    public RespondResult auditArticleContent(@RequestParam String articleId){
        return articleService.auditArticleContent(Long.parseLong(articleId));
    }

    @GetMapping("createdCategoryOfWeek")
    public RespondResult createdCategoryOfWeekStatistic(@RequestParam String categoryName){
        return articleService.createdCategoryOfWeekStatistic(categoryName);
    }

    @PutMapping("articlePass")
    public RespondResult articlePass(@RequestParam String articleId){
        return articleService.articlePass(Long.parseLong(articleId));
    }

    @PutMapping("articleNoPass")
    public RespondResult articleNoPass(@RequestParam String articleId){
        return articleService.articleNoPass(Long.parseLong(articleId));
    }
}
